import sqlite3

# 连接数据库
conn = sqlite3.connect("user_db.sqlite")
cursor = conn.cursor()

# 导出为 SQL 文件
with open("db.sql", "w", encoding="utf-8") as f:
    for line in conn.iterdump():
        f.write(f"{line}\n")

conn.close()
print("数据库已导出到 db.sql")
